package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.entity.Order;
import com.itheima.service.OrderService;
import com.itheima.vo.OrderPageResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**订单接口
 * @author msi
 */
@RequestMapping("/order")
@RestController
public class OderControllerM {
    @Resource
    private OrderService service;

    @GetMapping("/userPage")
    public R<OrderPageResultVO> getUserPage(Integer page, Integer pageSize) {

        OrderPageResultVO pageList = service.getPageList(page, pageSize);

        return R.success(pageList);
    }

    @PostMapping("/submit")
    public R<String> submit(@RequestBody Order order) {
        Boolean flag = service.insert(order);
        if (flag) {
            return R.success("提交成功");
        }
        return R.error("提交失败");
    }
}
